package cc.lucien.io;

import java.io.File;

public class FileTest {

    public static void main(String[] args) {
        File file = new File("D:/abc");
//        System.out.println(file.exists());
//        file.mkdirs();
        System.out.println(file.exists());
        deleteFile(file);
        System.out.println(file.exists());
    }

    public static void deleteFile(File file) {
        if (file.exists()) {
            if (file.isDirectory()) {
                File[] files = file.listFiles();
                for (File file1 : files) {
                    deleteFile(file1);
                }
            }
            file.delete();
        } else {
            System.out.println("该文件对象不存在！");
        }
    }
}
